#pragma once


/*
 * Functions to handle the terminal and its properties
 */


#include "bzbterm/termcolor.h"
#include "bzbstring/stringutils.h"


namespace bzbterm {


/*
 * Prints the specified escape sequence
 */

inline void set_esc_seq(EscSeq e) {
	std::cout << e;
}


/*
 * Changes the shell's font color
 */

inline void set_fg_color(unsigned int r, unsigned int g, unsigned int b) {

	std::cout << bzbstring::concat("\033[38;2;", r, ";", g, ";", b, "m");
}


/*
 * Changes the shell's font color
 */

inline void set_bg_color(unsigned int r, unsigned int g, unsigned int b) {

	std::cout << bzbstring::concat("\033[48;2;", r, ";", g, ";", b, "m");
}


/*
 * Clears the screen and resets the cursor to the top left corner
 */
inline void clear_screen() {
	std::cout << "\033[1;1H" << "\033[2J";
}


/*
 * Saves the screen's content for later restoring it
 */
inline void save_screen() {
	std::cout << "\033[?47h";
}


/*
 * Restore the screen's content as saved before
 */
inline void restore_screen() {
	std::cout << "\033[?47l";
}


/*
 * Clears the current line
 */
inline void clear_line() noexcept {
	std::cout << "\033[2K";
}


/*
 * Hide the cursor
 */
inline void show_cursor() noexcept {
	std::cout << "\033[?25h";
}


/*
 * Hide the cursor
 */
inline void hide_cursor() noexcept {
	std::cout << "\033[?25l";
}


}
